<?php  

/**
* Config
*/
class Config
{
  protected static $_instance;
  public static function getInstance(){
    if(self::$_instance==null){
      self::$_instance= new Config();
    }
    return self::$_instance;
  }
    
  protected function __construct()
  {
    $this->_vars = array();
  }
  
  protected $_vars;
  
  public function getVariable($name){
    return isset($this->_vars[$name]) ? $this->_vars[$name] : null;
  }
  
  public function setVariable($name, $value){
    $this->_vars[$name] = $value;
  }
  
  public function loadFromFile($file, $prefix='' ,$type='json'){
    $parser;
    switch ($type) {
      case 'json':
        import('miho.config.parser.JsonParser');
        $parser = new JsonParser($file);
        break;
      
      default:
        # code...
        break;
    }
    $parser->extractValues($prefix);
  }
  
  public function getFromFile($file, $type='json'){
    $parser;
    switch ($type) {
      case 'json':
        import('miho.config.parser.JsonParser');
        $parser = new JsonParser($file);
        break;
      
      default:
        # code...
        break;
    }
    
    return $parser;
  }
  
  public static function get($name){
    return Config::getInstance()->getVariable($name);
  }
  
  public static function set($name, $value){
    Config::getInstance()->setVariable($name, $value);
  }
}

?>